﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ByHand.Data;
using ByHand.Data.Interfaces;
using ByHand.Model;
using ByHand.Services.Interfaces;

namespace ByHand.Services.Implements
{
    public class DistrictService: RepositoryBase<District>, IDistrictService
    {
        public DistrictService(IDatabaseFactory DbFactory) : base(DbFactory) { }

        public List<District> GetByCity(int id) {
            return (from d in ByHandDB.Districts
                    where d.CityID == id
                    select d).ToList() ;
        }
        public List<District> GetByCity(City city) { 
            return (from d in ByHandDB.Districts
                    where d.CityID == city.ID
                    select d).ToList();
        }
        public List<District> GetByCity(string cityName) {
            return (from d in ByHandDB.Districts
                    join c in ByHandDB.Cities on d.CityID equals c.ID
                    where c.Name == cityName
                    select d).ToList();
        }
    }
}
